{%extends '../base/base.tpl'%}

{%block 'title'%}运营管理-商家管理{%/block%}

{%block 'header_css'%}
<link href="../../static/js/common/plugins/chosen/chosen.css?__inline" rel="stylesheet">
<link href="../../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="../../static/css/plugins/cropper/cropper.min.css" rel="stylesheet">  <!--图片上传加裁剪-->


<!-- 上传组件 -->
<link href="../../static/js/common/plugins/fileinput/fileinput.min.css" rel="stylesheet"/>
<!--富文本 -->
<link href="../../static/js/common/plugins/kindeditor/themes/qq/qq.css" rel="stylesheet"/>
<link href="../../static/css/animate.min.css" rel="stylesheet">
<link href="../../static/css/style.min.css?__inline" rel="stylesheet">
<link href="../../static/css/common.css?__inline" rel="stylesheet">


<style type="text/css">
table{font-size:13px;text-align:center;}
thead{font-weight:bold;text-align:center;}
th{text-align: center;}
.list_edit_table{}
.is_must{line-height: 34px;}
table a{display: inline-block;}
.img-preview-sm{height:78px;}
.note-editor .note-editable{background: #fff}
.note-editable{min-height: 200px;}
.tangram-suggestion-main{z-index: 10000}
.BMapLabel{margin-top: -20px;max-width: inherit;}
.btn-danger{background-color: #ec4758;border-color: #ec4758;color: #FFF;}
.btn-success{background-color: #1a7bb9;border-color: #1a7bb9;color: #FFF;}
</style>
{%/block%}

{%block 'header_js'%} 

{%/block%}

{%block 'foot'%}

{%/block%}

{%block 'body'%}
{%assign var=table_operation value="true" %}
{%assign var=table_btn value=array(
    [
        'url'=>'#',
        'text'=>'编辑',
        'type'=>'edit_btn',
        'data_target'=>'#table_detail',
        'data_toggle'=>'modal'
    ],
    [
        'url'=>'#',
        'text'=>'详情',
        'type'=>'detail_btn',
        'data_target'=>'#table_detail',
        'data_toggle'=>'modal'
    ],
    [
        'url'=>'#',
        'text'=>'删除',
        'type'=>'del_btn',
        'data_target'=>'null',
        'data_toggle'=>'null'
    ]
) %}
<div id="wrapper">
    {%include file="../../widget/left_menu.tpl"%}
    <div id="page-wrapper" class="gray-bg dashbard-1">
        {%include file="../../widget/header.tpl"%}
        <div class="row J_mainContent" id="content-main">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h3>商家管理</h3>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <form method="get" class="form-horizontal">
                            <div class="form-group">
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label">商家名称:</label>
                                    <div class="col-md-9">
                                        <input type="text" placeholder="商家名称" name="vender_name" id="vender_vender_name" class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label">商家类型:</label>
                                    <div class="col-md-9">
                                        <select class="form-control" name="vender_type" id="vender_vender_type">
                                            <option value="0">纯售票类商家</option>
                                            <option value="1">纯售实体商家</option>
                                            <option value="2">票类和实体都有销售</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label">关联标签:</label>
                                    <div class="col-md-9">
                                        <select class="form-control" name="tag" id="vender_tag">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label">城市:</label>
                                    <div class="col-md-9">
                                        <select class="form-control chosen-select" name="city_id" id="vender_city_id">
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label">区县:</label>
                                    <div class="col-md-9" id="regionWrap">
                                        <select class="form-control chosen-select" name="region_id" id="vender_region_id">
                                            <option value="">请先选择城市</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <label class="col-sm-3 control-label"></label>
                                    <div class="col-md-9" id="regionWrap">
                                        <button class="btn btn-primary pull-right"  type="submit"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <a type="button" href="#" class="btn btn-primary new_file_coupon" data-toggle="modal" data-target="#table_detail">新建商家</a>
                    {%include file="../../widget/table_mod.tpl"%}
                    {%include file="../../widget/pagination.tpl"%}
                </div>
            </div>
        </div>
        {%include file="../../widget/footer.tpl"%}
    </div>
</div>
{%include file="../../widget/editable_mod.tpl"%}
{%/block%}
  
{%block 'foot_js'%}
<script src="../../static/js/common/plugins/chosen/chosen.jquery.js?__inline"></script>
<script src="../../static/js/common/content.min.js"></script>
<script src="../../static/js/common/plugins/validate/jquery.validate.min.js"></script>
<script src="../../static/js/common/plugins/validate/messages_zh.min.js"></script>
<script src="../../static/js/common/jquery.form.js"></script>
<script src="../../static/js/common/plugins/layer/laydate/laydate.js"></script> 
<script src="../../static/js/common/plugins/sweetalert/sweetalert.min.js"></script>
<script src="../../static/js/common/plugins/jeditable/jquery.jeditable.js"></script> 
<script src="../../static/js/common/plugins/dataTables/jquery.dataTables.js"></script> 
<script src="../../static/js/common/plugins/dataTables/dataTables.bootstrap.js"></script> 
<script src="../../static/js/common/plugins/cropper/cropper.min.js"></script> 
<script src="../../static/js/common/plugins/ajaxfileupload/ajaxfileupload.js"></script> 
<!-- 上传组件 -->
<script src="../../static/js/common/plugins/fileinput/fileinput.min.js"></script>
<script src="../../static/js/common/plugins/fileinput/fileinput_locale_zh.js"></script>
<!-- 富文本 -->
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- <script src="../../static/js/table/tableoperation.js"></script> -->
<script src="../../static/js/table/tableModel.js"></script>
<script type="text/javascript">
var WinUrl = window.location.search;



function getUrlParam(name){   //获取URL参数值
    //构造一个含有目标参数的正则表达式对象  
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
    //匹配目标参数  
    var r = decodeURI(window.location.search.substr(1)).match(reg);  
    //返回参数值  
    if (r!=null) return unescape(r[2]);  
    return null;  
}  
$(function(){
  if(WinUrl.indexOf("vender_type") > 0){
      $("#vender_vender_type").val(getUrlParam('vender_type'))
  }
  if(WinUrl.indexOf("vender_name") > 0){
      $("#vender_vender_name").val(getUrlParam('vender_name'))
  }
  cityAjax();
  if($("#vender_city_id").val() != "" || $("#vender_city_id").val() != null && $("#vender_city_id").val() > 0){
      regionAjax($("#vender_city_id").val());
  }else{
  }
    function cityAjax(){
        $.ajax({
            url:"/ajax/call/basedata/city_list",
            type:'post',
            success:function(res){
                if(res.data_list!=undefined){
                    var dlist = res.data_list;
                    var html = '<option value="">未选择</option>';
                    for(var i = 0;i < dlist.length; i++ ){
                        // html +='<option value="'+dlist[i].city_id+'">'+dlist[i].city+'</option>'
                        if(WinUrl.indexOf("city_id") > 0 && getUrlParam('city_id') != null && getUrlParam('city_id') != ""){
                            if(getUrlParam('city_id') == dlist[i].city_id ){
                                html +='<option value="'+dlist[i].city_id+'" selected>'+dlist[i].city+'</option>'
                            }else{
                                html +='<option value="'+dlist[i].city_id+'" >'+dlist[i].city+'</option>'
                            }
                        }else{
                            html +='<option value="'+dlist[i].city_id+'" >'+dlist[i].city+'</option>'
                        }
                    }
                    $("#vender_city_id").html("").append(html);
                    $('#vender_city_id').chosen({});
                    $("#vender_city_id").change(function(){
                        if($(this).val() != "-1"){
                            regionAjax($(this).val());
                        }else{
                            $("#regionWrap").html("").append('<select class="form-control chosen-select" name="region_id" id="vender_region_id"><option value="">请先选择城市</option></select>')
                        }
                    });  
                }

            }  

        });
    }

    function regionAjax(city_id){
        $.ajax({
            url:"/ajax/call/basedata/region_list",
            type:'post',
            data:{
                "city_id":city_id
            },
            success:function(res){
                if(res.data_list!=undefined){
                    var dlist = res.data_list;
                    var html = '<option value="">未选择</option>';
                    for(var i = 0;i < dlist.length; i++ ){

                        if(WinUrl.indexOf("region_id") > 0 && getUrlParam('region_id') != null && getUrlParam('region_id') != ""){
                            if(getUrlParam('region_id') == dlist[i].region_id ){
                                html +='<option value="'+dlist[i].region_id+'" selected>'+dlist[i].region+'</option>'
                            }else{
                                html +='<option value="'+dlist[i].region_id+'">'+dlist[i].region+'</option>'
                            }
                        }else{
                            html +='<option value="'+dlist[i].region_id+'">'+dlist[i].region+'</option>'
                        }
                    }
                    $("#vender_region_id").html("").append(html);
                    $('#vender_region_id').chosen({});
                }
            }    
        });
    }
    tagAjax();
    function tagAjax(){
        $.ajax({
            url:"/ajax/call/basedata/tag_list",
            type:'post',
            success:function(res){
                if(res.data_list!=undefined){
                    var dlist = res.data_list;
                    var html = '<option value="">未选择</option>';
                    for(var i = 0;i < dlist.length; i++ ){
                        
                        if(WinUrl.indexOf("tag") > 0 && getUrlParam('tag') != null && getUrlParam('tag') != ""){
                            // $("#vender_tag").val(getUrlParam('tag'))
                            if(getUrlParam('tag') == dlist[i].name ){
                                html +='<option value="'+dlist[i].id+'" selected>'+dlist[i].name+'</option>'
                            }else{
                                html +='<option value="'+dlist[i].id+'" >'+dlist[i].name+'</option>'
                            }
                        }else{
                            html +='<option value="'+dlist[i].id+'" >'+dlist[i].name+'</option>'
                        }
                    }
                    $("#vender_tag").html("").append(html);
                    $('#vender_tag').chosen({});
                }

            }  

        });
    }
});
  

  
  
  

 

</script> 
{%/block%}

